
<template>
    <div>
        <div style="width: 100%;text-align: end;">
            <el-button type="primary" @click="toupload">新建</el-button>
        </div>
        <div style="width: 100%;" class="produce_list">
            <column style="flex: 1;" componentsType="management" @dirClick="dirClick" :documentType="documentType" :functionIndex="functionIndex" :data='prodForm' :listQuery="listQuery"></column>
            <!-- <div v-if="prodForm.length==0" class="prodece_data">
		<el-empty description="暂无数据"></el-empty>
	</div> -->
            <!-- <div class="document-right-content">
			<row :prodForm='prodForm'></row>
		</div> -->
        </div>
        <div class="proj_pagination">
            <pagination v-show="total>0" :total="total" :current.sync="listQuery.current" :size.sync="listQuery.size" @pagination="loadList" />
        </div>

    </div>
</template>

<script>
import pagination from "@/components/Pagination";
import { list, save } from "@/api/doc.js";
import column from "./column.vue";
import row from "./row.vue";
export default {
	props: ['form'],
    data() {
        return {
            prodForm: [],
            total: 0,
            documentType: "全部类型",
            functionIndex: 0,
            switchType: "row",
            listQuery: {
                current: 1,
                size: 10,
                docType: "02",
                deleted: 0,
                isUpdate: 0,
                isMyCreate: 0,
                name: "",
                docSubtype: "00",
                docTypeId: "",
            },
            // listQuery: {
            //     current: 1,
            //     size: 20,
            //     docType: "",
            //     dirId: "",
            //     deleted: 0,
            //     isUpdate: 0,
            //     isMyCreate: 0,
            //     name: "",
            // },
        };
    },
    components: {
        row,
        column,
		pagination
        // folder,evclosure
    },
    created() {
		this.loadList()
        this.$EventBus.$on("savemanagement", (data) => {
			this.loadList()
        });
        this.$EventBus.$on("updateDoc", (data) => {
            var _this = this;
            if (data.type == "del") {
                _this.prodForm.forEach(function (item, index) {
                    if (item.docId == data.data.docId) {
                        _this.prodForm.splice(index, 1);
                        _this.$forceUpdate();
                    }
                });
            } else if (data.type == "update") {
                _this.prodForm.forEach(function (item, index) {
                    if (item.docId == data.data.docId) {
                        _this.prodForm[index] = data.data;
                        _this.$forceUpdate();
                    }
                });
            }
        });
    },
    methods: {
        loadList() {
            var _this = this;
            list(_this.listQuery).then((res) => {
                _this.prodForm = res.data.docData;
                _this.total = res.data.docData.length;
            });
        },
        toupload() {
            this.$router.push({
                path: "/produce/upload",
                query: {
                    docSubtype: this.listQuery.docSubtype,
                    dirId: this.form.dirId,
                    docTypeId: this.$route.query.prodId,
                    prodId: this.$route.query.prodId,
                },
            });
        },
        dirClick(data) {
            this.resetClick();
            this.listQuery.docType = data.dirType;
            this.listQuery.dirId = data.dirId;
            this.loadList();
        },
        loadFolder(data) {
            this.$refs.folder.loadFolder(data);
        },
        loadEnclosure() {
            this.$refs.evclosures.loadEnclosure();
        },
        loadSwitch(data) {
            this.switchType = data;
        },
    },
};
</script>

<style scoped>
.document-right-content-column {
    margin-bottom: 20px;
    margin-right: 20px;
}
.produce_list {
    display: flex;
}
.prodece_data {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}
.proj_pagination {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 64px;
}
</style>
